{{/* Partial for built-in search and Algolia search. */}}
{{ $search_provider := lower site.Params.features.search.provider }}
{{ if in (slice "wowchemy" "algolia") $search_provider }}
<aside class="search-modal" id="search">
  <div class="container">
    <section class="search-header">

      <div class="row no-gutters justify-content-between mb-3">
        <div class="col-6">
          <h1>{{ i18n "search" }}</h1>
        </div>
        <div class="col-6 col-search-close">
          <a class="js-search" href="#" aria-label="{{i18n "close" | default "Close"}}"><i class="fas fa-times-circle text-muted" aria-hidden="true"></i></a>
        </div>
      </div>

      <div id="search-box">
        {{ if eq $search_provider "wowchemy" }}
        <input name="q" id="search-query" placeholder="{{i18n "search_placeholder"}}" autocapitalize="off"
        autocomplete="off" autocorrect="off" spellcheck="false" type="search" class="form-control"
        aria-label="{{i18n "search_placeholder"}}">
        {{ else }}
        <!-- Search box will appear here -->
        {{ end }}
      </div>

      {{ $search_queries := false }}
      {{ if isset site.Data (printf "search_queries.%s" .Site.Language.Lang) }}
        {{ $search_queries = index site.Data (printf "search_queries.%s" .Site.Language.Lang) }}
      {{ else if isset site.Data "search_queries" }}
        {{ $search_queries = site.Data.search_queries }}
      {{end}}

      {{ if $search_queries }}
      <div id="search-common-queries" class="pt-3">
        <div class="font-weight-bold pb-3">{{ i18n "search_common_queries" | default "Common searches" }}</div>
        <ul class="fa-ul">
          {{ range $search_queries }}
            <li class="pb-3">
              <a href="{{.link | relURL}}"><i class="fa-li fas fa-search" aria-hidden="true"></i><span class="pl-1">{{.query | markdownify | emojify}}</span></a>
            </li>
          {{ end }}
        </ul>
      </div>
      {{ end }}

    </section>
    <section class="section-search-results">

      <div id="search-hits">
        <!-- Search results will appear here -->
      </div>

    </section>
  </div>
</aside>
{{end}}
